<%--
  Created by IntelliJ IDEA.
  User: 闫佳宁
  Date: 2024/1/22
  Time: 9:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<html>
<head>
    <base href="<%=baseUrl%>">
    <title>录入员工信息</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">会议室名称</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="name" placeholder="请输入会议室名称">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">容量</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="capacity" placeholder="请输入会议室容量">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">地点</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="address" placeholder="请输入会议室地点">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="add">录入</button>
        </div>
    </div>
</form>

<script src="layui/layui.js"></script>
<script>

    layui.use(['form'], function () {
        var form = layui.form;
        var $ = layui.$;



        //表单的提交
        form.on('submit(add)', function (data) {
            $.ajax({
                url: 'boardroom?action=add',
                data: data.field,
                type: 'post',
                dateType: 'json',
                success(result) {
                    if (result.code == 0) {
                        layer.msg('添加成功', {icon: 6}, function () {
                            parent.layer.closeAll('iframe');

                        })
                    }else {
                        layer.msg(result.msg, {icon: 5});
                    }
                },
                error() {
                    layer.msg('请求失败', {icon: 5});
                }
            });

            //阻止表单自动提交
            return false;
        });
    });
</script>

</body>
</html>
